library(tidyverse)
library(magrittr)
library(lubridate)
library(scales)
library(matrixStats)
library(ggrepel)
library(broom)
library(glue)
library(pander)
library(plotly)
panderOptions("big.mark", ",")
panderOptions("table.split.table", Inf)
panderOptions("table.style", "rmarkdown")
theme_set(theme_bw())
Disclaimer: This very simple report was prepared by a bioinformatician with no experience in epidemiology or virology, and as such should be treated simply as an alternate viewpoint on the data, which I was simply unable to find elsewhere. Many other people exist with much greater expertise on this subject. However, I do hope this provides a useful perspective which is able to add constructively to the wider discussion.
Data was sourced from Johns Hopkins University (https://coronavirus.jhu.edu/), using the datasets provided by JHU at https://github.com/CSSEGISandData/COVID-19. JHU data is updated every 24 hours at approximately 23:59(UTC), which is about 10:30AM in Adelaide. As a result Australian numbers may lag local media reports.
Additionally, the official government figures at www.health.gov.au appear to lag media reports, likely to ensure accuracy of the official numbers. The official Australian numbers are not used for this analysis, instead relying on those provided by JHU. However, JHU are extremely careful and comprehensive in their sourcing of numbers and significant disparity is not expected. Live updates for Australia are available from https://covid-19-au.github.io/ for those who would like an up to the minute breakdown of confirmed cases.
confirmed <- url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv") %>%
read_csv() %>%
pivot_longer(
cols = ends_with("20"),
names_to = "date",
values_to = "confirmed"
) %>%
mutate(
date = str_replace_all(
date, "(.+)/(.+)/(.+)", "20\\3-\\1-\\2"
) %>%
ymd()
) %>%
dplyr::rename(
Country = `Country/Region`
) %>%
dplyr::mutate(
Country = case_when(
`Province/State` == "Hubei" ~ "China (Hubei)",
`Province/State` == "Hong Kong" ~ "Hong Kong",
grepl("China", Country) & !`Province/State` %in% c("Hubei", "Hong Kong") ~ "China (Other)",
!grepl("China", Country) ~ Country
)
) %>%
dplyr::filter(
!is.na(confirmed)
) # %>%
# bind_rows(
# tibble(
# Country = "Australia",
# date = ymd("2020-03-20"),
# confirmed = 876
# )
# )
Population sizes for the most impacted countries were manually obtained from https://www.worldometers.info/ and should not be considered as authoritative. Given the disparity of infection within China, China was broken into Hubei Province, Hong Kong and the rest of China. As an open acknowledgement of the crudeness of population values, population estimates for Hubei Province were taken from the 2018 estimates given by Statista.com. This particular population estimate is likely to be low, and as a result confirmed case rates for Hubei province may be an overestimate, and consequently, confirmed case rates for the rest of China may also be an underestimate.
Confirmed cases of COVID-19 as provided by the Chinese Government have been discussed elsewhere as unusual, and data appears potentially unreliable. In this analysis, discussions regarding accurate Chinese reporting are not considered further and data is simply presented as supplied by JHU.
However, all countries are likely to contain many unreported cases given the incomplete testing regimes in place for most countries. Similarly, reporting in many countries may have features that cause concerns regarding data integrity and this makes comparison across countries difficult.
hb <- 59170000
pops <- tribble(
~Country, ~Population,
"Australia", 25499884,
"Austria", 9006398,
"Belgium", 11575214,
"Brazil", 212129490,
"Canada", 37742154,
"China (Hubei)", hb,
"China (Other)", 1408526449 - hb,
"Czechia", 10703010,
"Denmark", 5786274,
"Finland", 5538181,
"France", 65273511,
"Germany", 83783942,
"Greece", 10423054,
"Hong Kong", 7479307,
"Italy", 60486925,
"Iran", 83677594,
"Ireland", 4921810,
"Israel", 8615601,
"Japan", 126476461,
"Korea, South", 51269185,
"Malaysia", 32245488,
"Netherlands", 17134872,
"New Zealand", 4811065,
"Norway", 5408930,
"Pakistan", 219629013,
"Portugal", 10196709,
"Qatar", 2866531,
"Singapore", 5836728,
"Spain", 46754778,
"Sweden", 10081035,
"Switzerland", 8654622,
"Taiwan*", 23804524,
"United Arab Emirates", 9856053,
"United Kingdom", 67886011,
"US", 331002651
)
All information presented in the section below is effectively the cumulative, confirmed incidence rate. Recovered patients and those who have passed away are still included in these numbers. Testing rates and results are also not included, and these may be highly informative if able to be sourced accurately.
confirmed %>%
group_by(Country, date) %>%
summarise(confirmed = sum(confirmed)) %>%
ungroup() %>%
group_by(Country) %>%
dplyr::filter(
date == max(date)
) %>%
ungroup() %>%
right_join(pops) %>%
mutate(
rate = 1e6*confirmed / Population
) %>%
arrange(desc(rate)) %>%
dplyr::slice(1:25) %>%
mutate(
rate = sprintf("%.1f", rate),
Population = comma(Population)
) %>%
rename_at(vars(everything()), str_to_title) %>%
rename(`Rate (Cases per Million)` = Rate) %>%
pander(
justify = "lrrrr",
caption = paste(
"The", nrow(.), "most impacted populations studied here and shown as a proportion of total population.",
"The final column provides the latest confirmed infection rate as cases per million people.",
"Whilst the virus spreads with no regard to population size, the rate as shown here indicates the degree of stress which each country's health-care system is likely to be experiencing.",
"Several countries shown here have not attracted much media attention due lower case numbers than China and Italy, but are likely to be experiencing significant duress."
)
)
| Country | Date | Confirmed | Population | Rate (Cases per Million) |
|---|---|---|---|---|
| China (Hubei) | 2020-03-19 | 67,800 | 59,170,000 | 1145.9 |
| Italy | 2020-03-19 | 41,035 | 60,486,925 | 678.4 |
| Switzerland | 2020-03-19 | 4,075 | 8,654,622 | 470.8 |
| Spain | 2020-03-19 | 17,963 | 46,754,778 | 384.2 |
| Norway | 2020-03-19 | 1,746 | 5,408,930 | 322.8 |
| Austria | 2020-03-19 | 2,013 | 9,006,398 | 223.5 |
| Iran | 2020-03-19 | 18,407 | 83,677,594 | 220.0 |
| Denmark | 2020-03-19 | 1,225 | 5,786,274 | 211.7 |
| Germany | 2020-03-19 | 15,320 | 83,783,942 | 182.9 |
| France | 2020-03-19 | 10,947 | 65,273,511 | 167.7 |
| Korea, South | 2020-03-19 | 8,565 | 51,269,185 | 167.1 |
| Qatar | 2020-03-19 | 460 | 2,866,531 | 160.5 |
| Belgium | 2020-03-19 | 1,795 | 11,575,214 | 155.1 |
| Netherlands | 2020-03-19 | 2,467 | 17,134,872 | 144.0 |
| Sweden | 2020-03-19 | 1,439 | 10,081,035 | 142.7 |
| Ireland | 2020-03-19 | 557 | 4,921,810 | 113.2 |
| Israel | 2020-03-19 | 677 | 8,615,601 | 78.6 |
| Portugal | 2020-03-19 | 785 | 10,196,709 | 77.0 |
| Finland | 2020-03-19 | 400 | 5,538,181 | 72.2 |
| Czechia | 2020-03-19 | 694 | 10,703,010 | 64.8 |
| Singapore | 2020-03-19 | 345 | 5,836,728 | 59.1 |
| US | 2020-03-19 | 13,677 | 331,002,651 | 41.3 |
| Greece | 2020-03-19 | 418 | 10,423,054 | 40.1 |
| United Kingdom | 2020-03-19 | 2,716 | 67,886,011 | 40.0 |
| Malaysia | 2020-03-19 | 900 | 32,245,488 | 27.9 |
minToInclude <- 5
startingPoint <- 1
nDays <- confirmed %>%
dplyr::filter(Country == "Hong Kong") %>%
group_by(Country, date) %>%
summarise(confirmed = sum(confirmed)) %>%
ungroup() %>%
left_join(pops) %>%
mutate(
rate = 1e6*confirmed / Population
) %>%
dplyr::filter(rate > startingPoint) %>%
nrow() %>%
subtract(1)
p <- confirmed %>%
group_by(Country, date) %>%
summarise(confirmed = sum(confirmed)) %>%
ungroup() %>%
right_join(pops) %>%
mutate(
rate = 1e6*confirmed / Population
) %>%
group_by(Country) %>%
dplyr::filter(
max(rate) > minToInclude
) %>%
ungroup() %>%
split(f = .$Country) %>%
lapply(function(x, r = startingPoint){
std <- min(dplyr::filter(x, rate > r)$date)
x %>%
dplyr::filter(date >= std) %>%
mutate(days = date - std)
}) %>%
bind_rows() %>%
mutate(
days = as.integer(days),
rate = round(rate, 2)
) %>%
dplyr::filter(days <= nDays) %>%
arrange(date) %>%
mutate(Country = fct_inorder(Country)) %>%
rename_all(str_to_title) %>%
ggplot(
aes(Days, Rate, colour = Country, Date = Date, Confirmed = Confirmed)
) +
geom_segment(
aes(x, y, xend = xmax, yend = ymax),
data = tibble(
x = 0,
y = 1,
xmax = c(20.5, 41, nDays),
ymax = 2^(xmax/ c(2, 4, 8))
),
inherit.aes = FALSE,
colour = "grey70",
linetype = 2
) +
geom_text(
aes(xmax, ymax, label = label),
data = tibble(
xmax = c(20.5, 41, nDays),
rate = c(2, 4, 8),
ymax = 2^(xmax/ rate),
label = glue::glue("Doubling in\n {rate} days")
),
colour = "grey70",
inherit.aes = FALSE
) +
geom_point() +
geom_line() +
scale_x_continuous(
expand = expand_scale(mult = c(0, 0.05)),
) +
scale_y_log10(
expand = expand_scale(mult = c(0, 0.05)),
) +
xlab(
paste(
"Days since passing",
startingPoint,
"confirmed case/million"
)
) +
ylab("Confirmed Infection Rate (cases/million)")
ggplotly(
p,
tooltip = c(
"Days", "Rate", "Country", "Date", "Confirmed"
))
Confirmed cases of COVID-19 for countries where the infection rate has exceeded 5 cases/million. Data is only shown for the first 53 calendar days since passing 1 confirmed case/million. Note that from the day records begin in this dataset, the confirmed infection rate in Hubei was 7.59 confirmed cases/million. Diagonal grey lines indicate a doubling in the infection rate every 2, 4, or 8 days. To hide a country, click on the country in the plot legend. Clicking again on the country in the legend will restore the data within the plot. Countries are shown in order of the date at which they passed the 1 confirmed case/million mark. Due to the number of countries shown, you may need to scroll through the legend. Regions of the plot are also able to be zoomed interactively. Please note the y-axis is shown on the logarithmic scale, so that a series of points which appear to be diagonal will indicate exponential growth. The flatter the line, the slower the growth and a perfectly horizontal line would indicate zero growth, or no new confirmed cases.
All figures and tables presented here simply aim to show an alternative viewpoint on the data. Every way to view COVID-19 data will mask important features, and the values shown here do not take into account vital factors such as population density, variability of infection across regions within countries, social culture and demographics. Many countries may not be directly comparable for a combination of the above factors. It is simply to view the data through the lens of a country’s population size using a value which should be easily interpretable.
In the above plot:
Additionally, Australia’s spread of the virus appears marginally slower than many other countries.
Turning to other countries beyond Australia:
As an alternative viewpoint, the numbers of recovered and deceased patients have been removed from the above plot to provide an estimate of the currently active infections.
recovered <- url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv") %>%
read_csv() %>%
pivot_longer(
cols = ends_with("20"),
names_to = "date",
values_to = "recovered"
) %>%
mutate(
date = str_replace_all(
date, "(.+)/(.+)/(.+)", "20\\3-\\1-\\2"
) %>%
ymd()
) %>%
dplyr::rename(
Country = `Country/Region`
) %>%
dplyr::mutate(
Country = case_when(
`Province/State` == "Hubei" ~ "China (Hubei)",
`Province/State` == "Hong Kong" ~ "Hong Kong",
grepl("China", Country) & !`Province/State` %in% c("Hubei", "Hong Kong") ~ "China (Other)",
!grepl("China", Country) ~ Country
)
)
deaths <- url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv") %>%
read_csv() %>%
pivot_longer(
cols = ends_with("20"),
names_to = "date",
values_to = "deaths"
) %>%
mutate(
date = str_replace_all(
date, "(.+)/(.+)/(.+)", "20\\3-\\1-\\2"
) %>%
ymd()
) %>%
dplyr::rename(
Country = `Country/Region`
) %>%
dplyr::mutate(
Country = case_when(
`Province/State` == "Hubei" ~ "China (Hubei)",
`Province/State` == "Hong Kong" ~ "Hong Kong",
grepl("China", Country) & !`Province/State` %in% c("Hubei", "Hong Kong") ~ "China (Other)",
!grepl("China", Country) ~ Country
)
)
p2 <- confirmed %>%
dplyr::filter(
!str_detect(Country, "Other")
) %>%
left_join(recovered) %>%
left_join(deaths) %>%
mutate(
active = confirmed - recovered - deaths
) %>%
group_by(
Country, date
) %>%
summarise(
active = sum(active),
confirmed = sum(confirmed),
recovered = sum(recovered),
deaths = sum(deaths)
) %>%
right_join(pops) %>%
mutate(rate = 1e6*active / Population) %>%
dplyr::filter(
max(rate) > minToInclude
) %>%
ungroup() %>%
split(f = .$Country) %>%
lapply(function(x, r = startingPoint){
std <- min(dplyr::filter(x, rate > r)$date)
x %>%
dplyr::filter(date >= std) %>%
mutate(days = date - std)
}) %>%
bind_rows() %>%
mutate(
days = as.integer(days),
rate = round(rate, 2)
) %>%
dplyr::filter(days <= nDays) %>%
arrange(date) %>%
mutate(Country = fct_inorder(Country)) %>%
rename_all(str_to_title) %>%
ggplot(
aes(
x = Days, y = Rate, colour = Country,
Date = Date, Active = Active,
Confirmed = Confirmed, Recovered = Recovered,
Deaths = Deaths
)
) +
geom_segment(
aes(x, y, xend = xmax, yend = ymax),
data = tibble(
x = 0,
y = 1,
xmax = c(20.5, 41, nDays),
ymax = 2^(xmax/ c(2, 4, 8))
),
inherit.aes = FALSE,
colour = "grey70",
linetype = 2
) +
geom_text(
aes(xmax, ymax, label = label),
data = tibble(
xmax = c(20.5, 41, nDays),
rate = c(2, 4, 8),
ymax = 2^(xmax/ rate),
label = glue::glue("Double in\n {rate} days")
),
colour = "grey70",
inherit.aes = FALSE
) +
geom_point() +
geom_line() +
scale_y_log10() +
xlab(
paste(
"Days since passing",
startingPoint,
"confirmed active case/million"
)
) +
ylab("Confirmed Active Infections (cases/million)")
ggplotly(p2)
Confirmed active cases of COVID-19 for countries where the confirmed infection rate has exceeded 5 cases/million. Data is only shown for the first 53 calendar days since passing 1 confirmed case/million. Due to difficulties introduced by the currently reported low active infection rate outside Hubei province, data from China has been excluded from this plot, with the exception of Hubei. To hide a country, click on the country in the plot legend. Clicking again on the country in the legend will restore the data within the plot. Countries are shown in order of the date at which they passed the 1 confirmed active case/million mark. Due to the number of countries shown, you may need to scroll through the legend. Regions of the plot are also able to be zoomed interactively. Please note the y-axis is shown on the logarithmic scale, so that a series of points which appear to be diagonal will indicate exponential growth/decay.
Notable features of this perspective are:
Summarising all available data from all countries:
p4 <- confirmed %>%
dplyr::filter(
confirmed > 100,
Country != "Cruise Ship"
) %>%
left_join(recovered) %>%
left_join(deaths) %>%
mutate(
active = confirmed - recovered - deaths
) %>%
group_by(
Country, date
) %>%
summarise(
confirmed = sum(confirmed),
active = sum(active),
recovered = sum(recovered),
deaths = sum(deaths)
) %>%
group_by(Country) %>%
dplyr::filter(date == max(date)) %>%
ungroup() %>%
mutate(
active = 100*active / confirmed,
recovered = 100*recovered / confirmed,
fatalities = 100*deaths / confirmed
) %>%
dplyr::filter(active < 100) %>%
arrange(desc(confirmed)) %>%
mutate(Country = fct_inorder(Country)) %>%
pivot_longer(
cols = c(active, recovered, fatalities),
names_to = "Status",
values_to = "Percentage"
) %>%
mutate(
Status = str_to_title(Status),
Status = factor(
Status,
levels = c("Active", "Recovered", "Fatalities")
),
Percentage = round(Percentage, 2)
) %>%
mutate(confirmed = comma(confirmed)) %>%
rename(Confirmed = confirmed) %>%
ggplot(
aes(
Country, Percentage,
fill = Status, cases = Confirmed
)
) +
geom_col() +
scale_fill_manual(
values = c(
Active = "blue",
Recovered = "green",
Fatalities = "red"
)
) +
scale_y_continuous(expand = expand_scale(0, 0)) +
coord_flip() +
theme(
legend.position = "none"
)
ggplotly(p4)
Fatality, Recovery and Active Infection rates for countries which have exceeded 100 confirmed cases. Countries are shown in order of the number of confirmed cases.
In order to summarise which countries are the most similar to each other, a Principal Component Analysis was performed. This enables the multi-dimensional data of the above plots to summarised in two dimensions. As missing data cannot be included in this analysis, several countries which are at earlier comparative time-points than Australia were omitted from this analysis.
nDays <- confirmed %>%
dplyr::filter(Country == "Australia") %>%
group_by(Country, date) %>%
summarise(confirmed = sum(confirmed)) %>%
ungroup() %>%
left_join(pops) %>%
mutate(
rate = 1e6*confirmed / Population
) %>%
dplyr::filter(rate > startingPoint) %>%
nrow() %>%
subtract(1)
pca <- confirmed %>%
group_by(Country, date) %>%
summarise(confirmed = sum(confirmed)) %>%
ungroup() %>%
right_join(pops) %>%
mutate(
rate = 1e6*confirmed / Population
) %>%
group_by(Country) %>%
dplyr::filter(
max(rate) > minToInclude
) %>%
ungroup() %>%
split(f = .$Country) %>%
lapply(function(x, r = startingPoint){
std <- min(dplyr::filter(x, rate > r)$date)
x %>%
dplyr::filter(date >= std) %>%
mutate(days = date - std)
}) %>%
bind_rows() %>%
mutate(
days = as.integer(days),
rate = round(rate, 2)
) %>%
dplyr::filter(days <= nDays) %>%
dplyr::select(-date, -confirmed, -Population) %>%
pivot_wider(
values_from = rate,
names_from = days
) %>%
as.data.frame() %>%
column_to_rownames("Country") %>%
as.matrix() %>%
.[!rowAnyNAs(.),] %>%
log() %>%
prcomp()
pca$x %>%
as.data.frame() %>%
rownames_to_column("Country") %>%
ggplot(aes(PC1, PC2, label = Country)) +
geom_point() +
geom_text_repel() +
xlab(
paste0(
"PC1 (",
percent(summary(pca)$importance["Proportion of Variance","PC1"], accuracy = 0.1),
")"
)
) +
ylab(
paste0(
"PC2 (",
percent(summary(pca)$importance["Proportion of Variance","PC2"], accuracy = 0.1),
")"
)
)
Dimensional reduction showing which countries are most similar to each other at the 18 day mark. The value 18 days was chosen as this marks how long Australia has been passed 1 case/million. Countries which have not progressed beyond 1 case/million for 18 days or more are not shown. Principal Component 1, on the x-axis, corresponds to the greatest source of variability within the data (92.5%), and countries which appear near each other along this axis can be assumed to be showing similar growth in confirmed infection rates at this time point. Separation along the y-axis is less significant, but also worthy of note, as this represents 5.0% of variability within the data. At this early point, Australia’s cumulative, confirmed infection rate is diverging from countries which have responded well and is more similar to Israel. This is strongly suggestive the early measures instituted in Australia have been inadequate.
Australian State populations were taken from the ABS Website and were accurate in Sept 2019. The difference with previous estimates used above was within 0.04%, and as such no adjustments were made.
ausPops <- tribble(
~State, ~Population,
"New South Wales", 8117976,
"Victoria", 6629870,
"Queensland", 5115451,
"South Australia", 1756494,
"Western Australia", 2630557,
"Tasmania", 535500,
"Northern Territory", 245562,
"Australian Capital Territory", 428060
)
minRate <- 3
p5 <- confirmed %>%
dplyr::filter(
Country == "Australia"
) %>%
dplyr::rename(State = `Province/State`) %>%
left_join(ausPops) %>%
mutate(
Rate = round(1e6*confirmed / Population, 2),
Date = format.Date(date, "%d-%B")
) %>%
dplyr::filter(
!is.na(Population),
!str_detect(State, "Territory"),
Rate > minRate
) %>%
arrange(date) %>%
mutate(
State = fct_inorder(State)
) %>%
dplyr::rename(
Confirmed = confirmed
) %>%
ggplot(
aes(
x = date, y = Rate, colour = State,
label = Date, key = Confirmed
)
) +
geom_point() +
geom_smooth(
method = "lm",
se = FALSE,
show.legend = FALSE
) +
geom_line(linetype = 3) +
scale_y_log10() +
labs(
x = "Date",
y = "Confirmed Infection Rate (cases/million)"
)
# Hide the tooltip from the regression lines
n <- length(levels(p5$data$State))
p5 <- ggplotly(p5, tooltip = c("Date", "Rate", "State", "Confirmed"))
regIndex <- seq(n + 1, length.out = n, by = 1)
p5$x$data[regIndex] <- lapply(
p5$x$data[regIndex],
function(x){
x$hoverinfo <- "none"
x
})
p5
Infection rates for each state with data beginning for each state once 3 confirmed cases /million was exceeded. Linear regression lines are shown for each state as the solid lines, with NSW perhaps showing a slightly increased rate of infection within the population. Once again, the y-axis is on a logarithmic scale indicating exponential growth is occurring. States are shown in order of the initial date they passed 3 cases/million. Due to the low population sizes in the ACT and NT, these territories were omitted.
In order to test whether the infection rates are different between states, a linear regression model was fit. \(\log_{10}\)(Cumulative Confirmed Infection Rate) was assigned as the response variable with predictor variables being the State and Date. Each State was assigned it’s own intercept and slope by use of an interaction term (i.e. State:date). Given the potentially larger slope in NSW, this state was set as the baseline, with each other slope (i.e. interaction term) being presented as the difference in slope between each state and NSW. In this way comparisons against NSW were performed, but no comparisons between other states were performed.
Differences in the State-level intercepts are not particularly relevant, apart from capturing the initial cumulative confirmed infection rate exceeded 3 cases / million. Differences between State-level slopes and NSW however, are of great interest, and as such only the slopes are shown. For NSW (Term = date) this captures the actual slope of the daily change in infection rate, whilst for all other States, this represents the difference between the daily change in infection rate for that State in comparison to NSW. Only differences in slope with an FDR-adjusted p-value < 0.05 are of particular interest. For those States which appear to be of interest, a negative value indicates an infection rate increasing more slowly than NSW, whilst a positive value indicates the opposite..
lm <- confirmed %>%
dplyr::filter(
Country == "Australia"
) %>%
dplyr::rename(State = `Province/State`) %>%
left_join(ausPops) %>%
mutate(
Rate = round(1e6*confirmed / Population, 2),
Date = format.Date(date, "%d-%B")
) %>%
dplyr::filter(
!is.na(Population),
!str_detect(State, "Territory"),
Rate > minRate
) %>%
arrange(desc(confirmed)) %>%
mutate(
State = fct_inorder(State)
) %>%
dplyr::rename(
Confirmed = confirmed
) %>%
with(
lm(log10(Rate) ~ (State + date)^2)
)
lm %>%
tidy() %>%
mutate(
FDR = p.adjust(p.value, method = "fdr"),
term = str_remove_all(term, "State")
) %>%
rename(
Term = term,
Estimate = estimate,
SE = std.error,
`T` = statistic,
p = p.value
) %>%
dplyr::filter(
str_detect(Term, "date")
) %>%
mutate(
Estimate = sprintf("%.4f", Estimate),
SE = sprintf("%.3f", SE),
`T` = sprintf("%.2f", `T`),
p = case_when(
p < 1e-4 ~ sprintf("%.2e", p),
p >= 1e-4 ~ sprintf("%.4f", p)
),
FDR = case_when(
FDR < 1e-4 ~ sprintf("%.2e", FDR),
FDR >= 1e-4 ~ sprintf("%.4f", FDR)
)
) %>%
pander(
justify = "lrrrrr",
emphasize.strong.rows = which(
as.numeric(.$FDR) < 0.05 & .$Term != "date"
),
caption = paste(
"*Results of linear regression analysis",
"comparing the slopes of lines which track __daily",
"change in cumulative confirmed infection rates__,",
"scaled for population size in each state.",
"Intercept terms are not shown.",
"All states are shown in comparison to NSW",
"with Queensland and Victoria appearing to show",
"infection rates increasing __faster__ than in NSW,",
"whilst SA appears to be progressing at a __slower",
"rate than NSW__.",
"No difference was evident between WA and NSW or TAS and NSW.",
"These results are less conclusive than they may",
"initially appear as the multiple days at the",
"same count for SA and TAS may have lead to",
"violations of model assumptions.",
"Whilst diagnostic plots visually appeared",
"to be within acceptable bounds for real data,",
"the fitted model failed the Shapiro-Wilk Test",
"for normality",
paste0(
"(p = ",
sprintf(
"%.4f", shapiro.test(resid(lm))$p.value
),
")."
),
"Assuming these results hold, it can be inferred",
"that the increase in infection rate for SA",
"is also lower than in QLD and VIC.*"
)
)
| Term | Estimate | SE | T | p | FDR |
|---|---|---|---|---|---|
| date | 0.0836 | 0.004 | 21.19 | 2.03e-28 | 1.26e-27 |
| Queensland:date | 0.0180 | 0.008 | 2.36 | 0.0219 | 0.0329 |
| Victoria:date | 0.0216 | 0.009 | 2.50 | 0.0152 | 0.0304 |
| Western Australia:date | 0.0118 | 0.009 | 1.36 | 0.1777 | 0.1777 |
| South Australia:date | -0.0146 | 0.006 | -2.61 | 0.0116 | 0.0304 |
| Tasmania:date | -0.0118 | 0.006 | -1.86 | 0.0685 | 0.0825 |
coef(lm) %>%
enframe(name = "Term", value = "coef") %>%
dplyr::filter(str_detect(Term, "date")) %>%
mutate(
slope = case_when(
str_detect(Term, "State") ~ coef[[1]] + coef,
!str_detect(Term, "State") ~ coef
),
Term = str_remove(Term, "State"),
State = str_remove(Term, ":date"),
State = str_replace(State, "date", "New South Wales")
) %>%
left_join(
confirmed %>%
dplyr::filter(
Country == "Australia",
date == max(date)
) %>%
rename(State = `Province/State`) %>%
dplyr::select(State, date, confirmed)
) %>%
mutate(
predicted = round(10^slope*confirmed, 0),
slope = percent(10^slope, accuracy = 0.1),
) %>%
dplyr::select(
State,
`Expected Daily Increase` = slope,
`Most Recent` = confirmed,
`Predicted For Next Day` = predicted
) %>%
pander(
justify = "lrrr",
caption = paste(
"Results from linear regression shown as the",
"expected daily increase in cases for the",
"current exponential growth phase.",
"Most recent values were taken from the official",
"figures on",
confirmed %>%
dplyr::filter(Country == "Australia") %>%
.[["date"]] %>%
max() %>%
format("%d %B, %Y."),
"Predictions are for",
confirmed %>%
dplyr::filter(Country == "Australia") %>%
.[["date"]] %>%
max() %>%
add(1) %>%
format("%d %B, %Y."),
"Standard errors for predictions have not been included."
)
)
| State | Expected Daily Increase | Most Recent | Predicted For Next Day |
|---|---|---|---|
| New South Wales | 121.2% | 307 | 372 |
| Queensland | 126.4% | 144 | 182 |
| Victoria | 127.4% | 121 | 154 |
| Western Australia | 124.6% | 52 | 65 |
| South Australia | 117.2% | 42 | 49 |
| Tasmania | 118.0% | 10 | 12 |
Taking the testing numbers manually from https://covid-19-au.github.io/, the number of tested individuals in each state was assessed as a function of State population size. All results are valid at the time of report generation.
tribble(
~State, ~Tested,
"New South Wales", 40651,
"Queensland", 29579,
"Victoria", 19337,
"Western Australia", 8603,
"South Australia", 13000,
"Tasmania", 807,
"Australian Capital Territory", 2062
) %>%
left_join(
confirmed %>%
dplyr::filter(
date == max(date)
) %>%
rename(
State = `Province/State`
)
) %>%
left_join(ausPops) %>%
mutate(
`Population Proportion` = Tested / Population,
`Proportion Positive` = confirmed / Tested,
`Proportion Negative` = 1 - `Proportion Positive`
) %>%
dplyr::select(
State, Tested, contains("Prop")
) %>%
arrange(desc(`Population Proportion`)) %>%
mutate_at(
vars(contains("Prop")),
percent,
accuracy = 0.01
) %>%
pander(
justify = "lrrrr",
caption = paste(
"*COVID-19 testing scaled by State population size.",
"Confirmed cases are assumed to be the tests",
"returning a positive result.",
"The current numbers available for SA are a",
"lower limit, so in reality, the proportion of",
"the population tested is higher, as is the",
"proportion of tests returning a negative result.*"
)
)
| State | Tested | Population Proportion | Proportion Positive | Proportion Negative |
|---|---|---|---|---|
| South Australia | 13,000 | 0.74% | 0.32% | 99.68% |
| Queensland | 29,579 | 0.58% | 0.49% | 99.51% |
| New South Wales | 40,651 | 0.50% | 0.76% | 99.24% |
| Australian Capital Territory | 2,062 | 0.48% | 0.19% | 99.81% |
| Western Australia | 8,603 | 0.33% | 0.60% | 99.40% |
| Victoria | 19,337 | 0.29% | 0.63% | 99.37% |
| Tasmania | 807 | 0.15% | 1.24% | 98.76% |
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
locale: LC_CTYPE=en_AU.UTF-8, LC_NUMERIC=C, LC_TIME=en_AU.UTF-8, LC_COLLATE=en_AU.UTF-8, LC_MONETARY=en_AU.UTF-8, LC_MESSAGES=en_AU.UTF-8, LC_PAPER=en_AU.UTF-8, LC_NAME=C, LC_ADDRESS=C, LC_TELEPHONE=C, LC_MEASUREMENT=en_AU.UTF-8 and LC_IDENTIFICATION=C
attached base packages: stats, graphics, grDevices, utils, datasets, methods and base
other attached packages: plotly(v.4.9.2), pander(v.0.6.3), glue(v.1.3.1), broom(v.0.5.4), ggrepel(v.0.8.1), matrixStats(v.0.55.0), scales(v.1.1.0), lubridate(v.1.7.4), magrittr(v.1.5), forcats(v.0.4.0), stringr(v.1.4.0), dplyr(v.0.8.4), purrr(v.0.3.3), readr(v.1.3.1), tidyr(v.1.0.2), tibble(v.2.1.3), ggplot2(v.3.2.1) and tidyverse(v.1.3.0)
loaded via a namespace (and not attached): Rcpp(v.1.0.3), lattice(v.0.20-40), assertthat(v.0.2.1), digest(v.0.6.25), mime(v.0.9), R6(v.2.4.1), cellranger(v.1.1.0), backports(v.1.1.5), reprex(v.0.3.0), evaluate(v.0.14), highr(v.0.8), httr(v.1.4.1), pillar(v.1.4.3), rlang(v.0.4.4), lazyeval(v.0.2.2), readxl(v.1.3.1), rstudioapi(v.0.11), data.table(v.1.12.8), rmarkdown(v.2.1), labeling(v.0.3), htmlwidgets(v.1.5.1), munsell(v.0.5.0), shiny(v.1.4.0), httpuv(v.1.5.2), compiler(v.3.6.3), modelr(v.0.1.6), xfun(v.0.12), pkgconfig(v.2.0.3), htmltools(v.0.4.0), tidyselect(v.1.0.0), fansi(v.0.4.1), viridisLite(v.0.3.0), later(v.1.0.0), crayon(v.1.3.4), dbplyr(v.1.4.2), withr(v.2.1.2), grid(v.3.6.3), xtable(v.1.8-4), nlme(v.3.1-144), jsonlite(v.1.6.1), gtable(v.0.3.0), lifecycle(v.0.1.0), DBI(v.1.1.0), cli(v.2.0.1), stringi(v.1.4.6), farver(v.2.0.3), promises(v.1.1.0), fs(v.1.3.1), xml2(v.1.2.2), generics(v.0.0.2), vctrs(v.0.2.3), tools(v.3.6.3), Cairo(v.1.5-10), hms(v.0.5.3), crosstalk(v.1.0.0), fastmap(v.1.0.1), yaml(v.2.2.1), colorspace(v.1.4-1), rvest(v.0.3.5), knitr(v.1.28) and haven(v.2.2.0)